package com.example.demo.Interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

//注册拦截器
//拦截规则，看你要拦截那些请求
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;


    public List<String> list = Arrays.asList("/user/login","/css/**","/js/**","/pic/**","/**/*.html");
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**").excludePathPatterns(list); //设置拦截器拦截的请求路径(/**表⽰拦截所
        // 设置拦截器排除拦截的路径  //这个写的是填写拦截的请求，/**代表拦截所有的请求
    }
}
